#define MAXGRID	100

struct appdata //allvarligt. det här får mig att hata.
{
	float4 color	: COLOR0;
	float2 tex		: texcoord;
	float timer;
};

struct vfconn
{
	float4 color	: COLOR0;
};

vfconn main(appdata IN,uniform sampler2D decal) {
	vfconn OUT;

   int i,j,k,kmax=250;
   float dcx,dcy,dxy;
   float value;
   float cx,cy,xi,yi,xip1,yip1;

	i = IN.tex.x;
	j = IN.tex.y;
	
	dcx = 8;
	dcy = 4;
	dxy = 2;


	cy = dcy + (j - MAXGRID/2) * dxy / (double)MAXGRID;
	cx = dcx + (i - MAXGRID/2) * dxy / (double)MAXGRID;
    xi = 0;
    yi = 0;
         for (k=0;k<kmax;k++) {
            xip1 = xi*xi - yi*yi - cx;
            yip1 = 2 * abs(xi*yi) - cy;
            xi = xip1;
            yi = yip1;
            if (xi*xi + yi*yi > 200)
               break;
         }
         
     value = sqrt(k / (float) kmax);
     value *= value;

	OUT.color = float4(0,value,0,1);
	return OUT;
}